<?php
/**
 * Created by litong on Date: 2019/4/10 0010 下午 2:17
 */

namespace utils;

class RequestUtil {
  /**
   * 返回工程的url地址
   * @param $server
   * @return string
   * 处理处理http://localhost:80/ibot-service-commons/index.php问题
   * 处理http://localhost:80/ibot-service-commons/index.php?name=litong问题
   */
  public static function getProjectURL($server){
    $pos=strpos($server['REQUEST_URI'],'?');
    if($pos){
      $explode = explode('?', $server['REQUEST_URI']);
      $projectName=$explode[0];
    }else{
      $projectName=$server['REQUEST_URI'];
    }
    $url=$server['REQUEST_SCHEME'].'://'.$server['SERVER_NAME'].':'.$server['SERVER_PORT'].$projectName;
    return $url;
  }
}